# -*- encoding:utf-8 -*-

from taobao.response import TaobaoResponse

class ItemGetResponse(TaobaoResponse):
    """ 调用 taobao.item.get 得到单个商品时 返回的response"""

    def __init__(self, rsp=None):
        """
            @ rsp : TaobaoResponse
        """
        self.item = None
        if rsp:
            self.item = rsp.getFirst()
            super(ItemGetResponse, self).__init__(rsp.body, 
              rsp.errorCode, rsp.msg, rsp.redirectUrl, 
              rsp.requestUrl, rsp.requestBody, rsp.requestParameters)
          
        else:
            super(ItemGetResponse, self).__init__()
    
    def setItem(self, item):
        self.item = item

    def getItem(self):
        return self.item
